package com.ushine.web.component.design.chain.salary.handler;

import com.ushine.web.component.design.chain.salary.config.AbstractSalaryCalculateHandler;
import com.ushine.web.component.design.chain.salary.model.SalaryCalculateBO;
import com.ushine.web.component.design.chain.salary.model.SalaryParamVO;
import com.ushine.web.component.http.HttpResponseVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @Author: yls
 * @Date: 2022/03/04 09:07
 * @Description: 初始化薪资计算准备工作
 * @Version 1.0
 */
@Slf4j
@Service
public class InitSalaryCalculateHandler extends AbstractSalaryCalculateHandler {

    @Override
    @Transactional(rollbackFor = Exception.class)
    public HttpResponseVO<Object> process(SalaryCalculateBO salaryCalculate) {
        boolean flag = true;
        /*
         * 开始准备工作
         */
        try {
            SalaryParamVO salaryParamVO = salaryCalculate.getSalaryParamVO();
            log.info("获取参数：{}", salaryParamVO);
        } catch (Exception e) {
            log.info("薪资计算的准备工作异常！", e);
            flag = false;
        }

        /*
         * 修改为可发布薪资状态
         */


        /*
         * 锁定补卡审批
         */

        /*
         * 确定最终状态
         */
        if (Boolean.FALSE.equals(flag)) {
            return new HttpResponseVO<>().error("薪资计算的准备工作异常，终结薪资计算流程！");
        }
        return new HttpResponseVO<>().ok("薪资计算的准备工作完成，可以开始薪资计算！",salaryCalculate);
    }

}
